package manong.beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;

public class Classes implements Cloneable, Serializable {

    private Integer id;
    private String className;
    private String classNumber;
    private Integer dayLimit;
    private Integer statu;
    private String mark;

    private static final long serialVersionUID = 1L;

    public Classes(Integer id, String className, String classNumber, Integer dayLimit, Integer statu, String mark) {
        this.id = id;
        this.className = className;
        this.classNumber = classNumber;
        this.dayLimit = dayLimit;
        this.statu = statu;
        this.mark = mark;
    }

 
    public Classes() {
        super();
    }

    public Integer getId() {
        return id;
    }

    public Classes withId(Integer id) {
        this.setId(id);
        return this;
    }

  
    public void setId(Integer id) {
        this.id = id;
    }

    public String getClassName() {
        return className;
    }

    public Classes withClassName(String className) {
        this.setClassName(className);
        return this;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getClassNumber() {
        return classNumber;
    }

    public Classes withClassNumber(String classNumber) {
        this.setClassNumber(classNumber);
        return this;
    }

    public void setClassNumber(String classNumber) {
        this.classNumber = classNumber;
    }

    public Integer getDayLimit() {
        return dayLimit;
    }

    public Classes withDayLimit(Integer dayLimit) {
        this.setDayLimit(dayLimit);
        return this;
    }

    public void setDayLimit(Integer dayLimit) {
        this.dayLimit = dayLimit;
    }

    public Integer getStatu() {
        return statu;
    }

    public Classes withStatu(Integer statu) {
        this.setStatu(statu);
        return this;
    }

    public void setStatu(Integer statu) {
        this.statu = statu;
    }


    public String getMark() {
        return mark;
    }


    public Classes withMark(String mark) {
        this.setMark(mark);
        return this;
    }

    public void setMark(String mark) {
        this.mark = mark;
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Classes other = (Classes) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getClassName() == null ? other.getClassName() == null : this.getClassName().equals(other.getClassName()))
            && (this.getClassNumber() == null ? other.getClassNumber() == null : this.getClassNumber().equals(other.getClassNumber()))
            && (this.getDayLimit() == null ? other.getDayLimit() == null : this.getDayLimit().equals(other.getDayLimit()))
            && (this.getStatu() == null ? other.getStatu() == null : this.getStatu().equals(other.getStatu()))
            && (this.getMark() == null ? other.getMark() == null : this.getMark().equals(other.getMark()));
    }


    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getClassName() == null) ? 0 : getClassName().hashCode());
        result = prime * result + ((getClassNumber() == null) ? 0 : getClassNumber().hashCode());
        result = prime * result + ((getDayLimit() == null) ? 0 : getDayLimit().hashCode());
        result = prime * result + ((getStatu() == null) ? 0 : getStatu().hashCode());
        result = prime * result + ((getMark() == null) ? 0 : getMark().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", className=").append(className);
        sb.append(", classNumber=").append(classNumber);
        sb.append(", dayLimit=").append(dayLimit);
        sb.append(", statu=").append(statu);
        sb.append(", mark=").append(mark);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public Classes clone() throws CloneNotSupportedException {
        return (Classes) super.clone();
    }

    public enum Column {
        id("id", "id", "INTEGER", false),
        className("class_name", "className", "VARCHAR", false),
        classNumber("class_number", "classNumber", "VARCHAR", false),
        dayLimit("day_limit", "dayLimit", "INTEGER", false),
        statu("statu", "statu", "INTEGER", false),
        mark("mark", "mark", "VARCHAR", false);

        private static final String BEGINNING_DELIMITER = "`";

        private static final String ENDING_DELIMITER = "`";

        private final String column;

        private final boolean isColumnNameDelimited;

        private final String javaProperty;

        private final String jdbcType;

        public String value() {
            return this.column;
        }

        public String getValue() {
            return this.column;
        }

        public String getJavaProperty() {
            return this.javaProperty;
        }

        public String getJdbcType() {
            return this.jdbcType;
        }

        Column(String column, String javaProperty, String jdbcType, boolean isColumnNameDelimited) {
            this.column = column;
            this.javaProperty = javaProperty;
            this.jdbcType = jdbcType;
            this.isColumnNameDelimited = isColumnNameDelimited;
        }


        public String desc() {
            return this.getEscapedColumnName() + " DESC";
        }

        public String asc() {
            return this.getEscapedColumnName() + " ASC";
        }

        public static Column[] excludes(Column ... excludes) {
            ArrayList<Column> columns = new ArrayList<>(Arrays.asList(Column.values()));
            if (excludes != null && excludes.length > 0) {
                columns.removeAll(new ArrayList<>(Arrays.asList(excludes)));
            }
            return columns.toArray(new Column[]{});
        }

        public String getEscapedColumnName() {
            if (this.isColumnNameDelimited) {
                return new StringBuilder().append(BEGINNING_DELIMITER).append(this.column).append(ENDING_DELIMITER).toString();
            } else {
                return this.column;
            }
        }
    }
}